#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = (1 << 18) + 5;
const int MOD = 998244353;
ll fastpow(ll b, ll p) {
  ll res = 1;
  while (p) {
    if (p & 1) res = res * b % MOD;
    b = b * b % MOD;
    p >>= 1;
  }
  return res;
}
const int G = 3, invG = fastpow(G, MOD - 2);

int n;
int fac[N], ifac[N], pw[N * 6], c[7];
void init_fac(int n) {
  fac[0] = 1, ifac[0] = 1;
  rep(i, 1, n) fac[i] = 1ll * fac[i - 1] * i % MOD;
  ifac[n] = fastpow(fac[n], MOD - 2);
  per(i, n - 1, 1) ifac[i] = 1ll * ifac[i + 1] * (i + 1) % MOD;
}
ll cmb(ll n, ll m) {
  if (n < 0 || m < 0 || m > n) return 0;
  return (ll)fac[n] * ifac[m] % MOD * ifac[n - m] % MOD;
}

int rev[N];
int f[N], g[N];
void init_rev(int n) {
  rev[0] = 0;
  rep(i, 1, n - 1) rev[i] = (rev[i >> 1] >> 1) + (i & 1 ? n / 2 : 0);
}
void ntt(int a[N], int n, bool invert) {
  rep(i, 0, n - 1) if (i < rev[i]) swap(a[i], a[rev[i]]);

  for (int len = 2; len <= n; len <<= 1) {
    ll w1 = fastpow(invert ? invG : G, (MOD - 1) / len);
    for (int i = 0; i < n; i += len) {
      ll w = 1;
      for (int j = 0; j < len / 2; j++) {
        ll u = a[i + j], v = a[i + j + len / 2] * w % MOD;
        a[i + j] = (u + v) % MOD;
        a[i + j + len / 2] = (u - v + MOD) % MOD;
        w = w * w1 % MOD;
      }
    }
  }
  if (invert) {
    ll m = fastpow(n, MOD - 2);
    rep(i, 0, n - 1) a[i] = a[i] * m % MOD;
  }
}
void multiply(int f[N], int g[N], int n) {
  init_rev(n);
  ntt(f, n, 0), ntt(g, n, 0);
  rep(i, 0, n - 1) f[i] = 1ll * f[i] * g[i] % MOD;
  ntt(f, n, 1);
}

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  init_fac(n);
  pw[0] = 1;
  rep(i, 1, N * 6 - 1) pw[i] = pw[i - 1] * 10ll % MOD;
  int dig = 1, nxt = 10;
  rep(i, 1, n) {
    if (i == nxt) dig++, nxt *= 10;
    c[dig]++;
  }

  f[0] = 1;
  int len = 1, tot = 1;
  rep(k, 1, 6) {
    tot += c[k];
    while (len < tot) len <<= 1;
    rep(i, 0, c[k]) g[i] = cmb(c[k], i) * pw[k * i] % MOD;
    rep(i, c[k] + 1, len - 1) g[i] = 0;
    multiply(f, g, len);
  }

  ll ans = 0;
  int l = 1, r = min(10, n + 1);  // [l, r)
  rep(k, 1, 6) {
    if (!c[k]) break;
    g[n] = 0;
    ll p = fastpow(pw[k], MOD - 2);
    per(i, n, 1) g[i - 1] = p * (f[i] - g[i] + MOD) % MOD;
    ll b = 0;
    rep(i, 0, n) {
      b = (b + (ll)g[i] * fac[i] % MOD * fac[n - 1 - i] % MOD) % MOD;
    }
    ll sum = 1ll * (r - 1 + l) * (r - l) / 2 % MOD;
    ans = (ans + sum * b % MOD) % MOD;
    l = r;
    r = min(r * 10, n + 1);
  }
  cout << ans;
  return 0;
}